﻿<?php
//取网站根目录
error_reporting(0);
if($_GET['p'] == "1"){
$mc = $_FILES["file1"]["tmp_name"];
if($mc == ""){
echo '还没有选择文件<a href="sc.php" style="text-decoration:none;" >重新上传</a>';
}else{  
$name=$_FILES['file1']['name'];
$type=strstr($name,"."); 
if($type != ".jpg" and $type != ".png" and $type != ".gif"){  
echo '文件不是JPG或者GIF图片！<a href="sc.php" style="text-decoration:none;" >重新上传</a>';
}else{
move_uploaded_file($_FILES["file1"]["tmp_name"],"img/" . $_FILES["file1"]["name"]);
?>
<strong><span style="color:#337fe5;">啦啦~上传成功！要 </span></strong><strong><span style="color:#9933e5;">
<a href="sc.php" style="text-decoration:none;" >重新上传</a></span></strong><strong><span style="color:#337fe5;">吗</span></strong>
<script>window.parent.backfn.apply(this,["<?php echo $_FILES["file1"]["name"]; ?>"]);</script>
<?php 
}}}else{
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<form action="sc.php?p=1" method="post" enctype="multipart/form-data" id="upfrm"> 
<input type="file" name="file1" /> 
<input type="submit" value="上传" />
</form>

<?php } ?>